﻿#查找路径下面所有源文件
aux_source_directory(. SRC_LIST)

#生成文件
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")  
    configure_file(iconv.h.in ${CMAKE_CURRENT_SOURCE_DIR}/iconv/iconv.h)
    configure_file(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/iconv/config.h)
    configure_file(loop_unicode.h.in ${CMAKE_CURRENT_SOURCE_DIR}/iconv/loop_unicode.h)
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Windows") 
    configure_file(iconv.h.inn ${CMAKE_CURRENT_SOURCE_DIR}/iconv/iconv.h)
    configure_file(config.h.inn ${CMAKE_CURRENT_SOURCE_DIR}/iconv/config.h)
    configure_file(loop_unicode.h.inn ${CMAKE_CURRENT_SOURCE_DIR}/iconv/loop_unicode.h)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")

#设置debug项目名后缀
set(CMAKE_DEBUG_POSTFIX "_gd")

#引用当前文件夹
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/iconv)

#设置预处理
add_definitions(-DXTTO_EXPORTS)

#设置静态库
add_library(commonLibUtil STATIC ${SRC_LIST})

#设置预编译
SET_TARGET_PROPERTIES(commonLibUtil PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "stdafx.h")
cotire(commonLibUtil)

#设置目录
set_target_properties(commonLibUtil PROPERTIES FOLDER "CommonLib")

#复制头文件到inchhvi
install(FILES util.h DESTINATION ${PROJECT_SOURCE_DIR}/3rdlib/include/common)

install(TARGETS commonLibUtil 
        RUNTIME DESTINATION ${PROJECT_BINARY_DIR}/bin
		ARCHIVE DESTINATION ${PROJECT_SOURCE_DIR}/3rdlib/lib)


